package com.mfl.controller.admin;

import com.mfl.common.PageResult;
import com.mfl.common.Result;
import com.mfl.pojo.dto.RemarkPageQueryDTO;
import com.mfl.pojo.dto.RemarkQueryUserNameDTO;
import com.mfl.pojo.vo.RemarkPageQueryVO;
import com.mfl.pojo.vo.RemarkQueryUserNameVO;
import com.mfl.service.RemarkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("adminRemarkController")
@RequestMapping("/cky/admin/remark")
@Slf4j
public class RemarkController {

    @Autowired
    private RemarkService remarkService;

    /**
     * 分页查询评论
     * @param remarkPageQueryDTO
     * @return
     */
    @GetMapping("/pageQueryRemark")
    public Result<PageResult> pageQueryRemark(RemarkPageQueryDTO remarkPageQueryDTO){
        log.info("分页查询评论：{}", remarkPageQueryDTO);
        PageResult pageResult = remarkService.pageQuery(remarkPageQueryDTO);
        return Result.success("",pageResult);
    }

    /**
     * 批量删除评论
     * @param ids
     * @return
     */
    @DeleteMapping("/batchDelete")
    public Result batchDelete(@RequestParam List<Integer> ids){
        log.info("批量删除评论：{}", ids);
        remarkService.batchDelete(ids);
        return Result.success("删除成功");
    }

    /**
     * 查询评论过的用户
     * @return
     */
    @GetMapping("/queryUserName")
    public Result<List<RemarkQueryUserNameVO>> queryUserName(RemarkQueryUserNameDTO remarkQueryUserNameDTO){
        log.info("查询评论过的用户：{}", remarkQueryUserNameDTO);
        List<RemarkQueryUserNameVO> remarkQueryUserNameVOList = remarkService.queryUserName(remarkQueryUserNameDTO);
        return Result.success("", remarkQueryUserNameVOList);
    }
}
